float4x4 World;
float4x4 View;
float4x4 Projection;
uniform extern texture UserTexture;
float GlowIntensity;
float4 LensPosition;


sampler textureSampler = sampler_state
{
    Texture = <UserTexture>;
    mipfilter = LINEAR;  
    magfilter = LINEAR;  
    minfilter = LINEAR;  
    AddressU = Wrap;
    AddressV = Wrap;
};
 
// TODO: add effect parameters here.

struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 UV : TEXCOORD0;

    // TODO: add input channels such as texture
    // coordinates and vertex colors here.
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float2 UV : TEXCOORD0;

    // TODO: add vertex shader outputs such as colors and texture
    // coordinates here. These values will automatically be interpolated
    // over the triangle, and provided as input to your pixel shader.
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

float s = 15;
    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	output.UV =  input.UV;
    // TODO: add your vertex shader code here.

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.
float4 colorout = tex2D(textureSampler, input.UV) * GlowIntensity;
return colorout;
}

float4 FairyPS(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.
float4 colorout = tex2D(textureSampler, input.UV);
colorout.w = length(colorout.xyz);
return colorout;
}



VertexShaderOutput vsLens(VertexShaderInput input)
{
    VertexShaderOutput output;

float4 o = input.Position * LensPosition.z  * GlowIntensity* GlowIntensity;
o.z = 0;
o.w = 1;

    float4 worldPosition = mul(o + LensPosition, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	output.UV =  input.UV;
    // TODO: add your vertex shader code here.

    return output;
}

float4 psLens(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.
float4 colorout = tex2D(textureSampler, input.UV) * GlowIntensity;
return colorout;
}


technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
    pass Pass2
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 FairyPS();
    }
    pass Pass3
    {
        // TODO: set renderstates here.

        VertexShader = compile vs_2_0 vsLens();
        PixelShader = compile ps_2_0 psLens();
    }
}
